#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//

void solve()
{
	string s;
	cin>>s;
	bool ok=true;
	map<char,int> mp;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='r'||s[i]=='g'||s[i]=='b') mp[s[i]]=1;
		else
		{
			if(s[i]=='R'&&mp['r']!=1) ok=false;
			if(s[i]=='G'&&mp['g']!=1) ok=false;
			if(s[i]=='B'&&mp['b']!=1) ok=false;
		}
	}
	if(ok) cout<<"YES"<<'\n';
	else cout<<"NO"<<'\n';
	




}

int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}
//小写key,大写door